package com.base.controller;

import com.base.comm.CommContent;
import com.base.po.voip_coupon.CouponCategory;
import com.base.service.COUPON.CouponCategoryService;
import com.base.service.LogsService;
import com.base.utils.Produce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 添加365优惠券分类信息服务端
 * 
 * @author K
 *
 */
@Controller
@RequestMapping("/admin")
public class add_CouponCategory {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private CouponCategoryService couponCategoryService; // 商品分类信息

	// 添加商品分类信息
	@RequestMapping(value = "/toAddCouponCategory", method = RequestMethod.POST)
	public @ResponseBody int toAddCouponCategory(HttpServletRequest request, @RequestBody CouponCategory couponCategory) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return -1; // 未登录
		couponCategory.setId(Produce.getUUID()); // 设置参数 主键ID
		couponCategory.setParentid(userid); // 代理商ID
		couponCategory.setDatastatus((byte) 1); // 数据状态
		return couponCategoryService.insertSelective(couponCategory); // 添加
	}
}
